﻿#ifndef __AF_BUNDLE_H__
#define __AF_BUNDLE_H__

#include "AF_Define.h"

namespace AF
{
	class Bundle;
}
typedef AF::Bundle			AF_CBundle;

#include "AF_Table.h"

namespace AF
{
	/// 类型集合类
	class Bundle
	{
	private:
		enum ArgKind
		{
			ARG_UNKOWN	= 0,
			ARG_BOOLEAN,		// b
			ARG_INTEGER,		// i
			ARG_LONG,		// l
			ARG_FLORT,		// f
			ARG_DOUBLE,		// d
			ARG_CHARS,		// c
			ARG_STRING,		// s
			ARG_POINTER		// p
		};

		struct Arg
		{
			Pointer		pArg;
			ArgKind		kind;
		};

	public:
		Bundle();
		~Bundle();

	public:
		bool			PutBoolean(_STRING strKey, bool b);
		bool			PutInteger(_STRING strKey, int n);
		bool			PutLong(_STRING strKey, long l);
		bool			PutFloat(_STRING strKey, float f);
		bool			PutDouble(_STRING strKey, double d);
		bool			PutChars(_STRING strKey, char* sz);
		bool			PutString(_STRING strKey, _STRING str);
		bool			PutPointer(_STRING strKey, Pointer p);

		bool			GetBoolean(_STRING strKey);
		int			GetInteger(_STRING strKey);
		long			GetLong(_STRING strKey);
		float			GetFloat(_STRING strKey);
		double			GetDouble(_STRING strKey);
		char*			GetChars(_STRING strKey);
		_STRING			GetString(_STRING strKey);
		Pointer			GetPointer(_STRING strKey);

		void			Clean();

	private:
		Arg&			FindArg(_STRING strKey);
		bool			PutArg(_STRING strKey, Pointer pArg, ArgKind kind);
		bool			ChangeArg(_STRING strKey, Pointer pArg, ArgKind kind);

	private:
		Table<Arg>		m_tabArgs;
		Arg			m_ArgTemp;
	};
}

#endif